from urllib import request
from urllib import parse

date_str = parse.urlencode({
    "name":"奇酷教育",
    "address":"东三街"
})
print(date_str)
url = f"http://httpbin.org/get?{date_str}"
print(f"请求的url",url)

# 构建请求对象
req = request.Request(url,headers={
    "user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
    "content-type":"application/json"
})
res = request.urlopen(req)
print('请求头',req.headers)
print('响应头',res.headers)
print('响应结果',res.read().decode())